package hello.app.component;

import hello.app.R;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class ListItemAdapter extends ArrayAdapter<ListItem> {

	public ListItemAdapter(Context context, int textViewResourceId, ArrayList<ListItem> items) {
		super(context, textViewResourceId, items);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = convertView;
		if (view == null) {
			LayoutInflater inflater = (LayoutInflater) getContext()
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = inflater.inflate(R.layout.contact_row, null);
		}
		ListItem item = getItem(position);
		if (item != null) {
			TextView col = (TextView)view.findViewById(R.id.colTextView);
			//TextView textView1 = (TextView) view.findViewById(android.R.id.text1);
			TextView val = (TextView)view.findViewById(R.id.valTextView);
			//TextView textView2 = (TextView) view.findViewById(android.R.id.text2);
			col.setText(item.getColumn());
			val.setText(item.getValue());
			//textView1.setText(item.getColumn());
			//textView2.setText(item.getValue());
		}
		return view;
	}
}
